package com.uzai.console.web.alipay;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.uzai.console.dto.alipaydetail.AlipayDetailAlipayUrlDao;
import com.uzai.console.dto.alipaydetail.AlipayDetailQuery;
import com.uzai.console.enums.AlipayTypeEnum;
import com.uzai.console.service.alipaydetail.AlipayDetailService;
import com.uzai.console.service.alipaydetail.AlipayTradeSyncService;
import com.uzai.console.vo.alipaydetail.AlipayDetailCreateVo;
import com.uzai.console.vo.alipaydetail.AlipayDetailInfoVo;
import com.uzai.console.vo.base.SelectKeyVo;
import com.uzai.console.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * 设备监控
 * @author liuqi
 * @date 2021年08月16日 15:11
 */
@Api(value = "支付宝明细",tags = "交易明细|支付宝明细")
@ApiSort(17)
@RestController
public class AlipayDetailController extends BaseController {
    private Logger logger = LoggerFactory.getLogger(AlipayDetailController.class);

    @Autowired
    private AlipayDetailService alipayDetailService;

    @ApiOperation(value = "分页查询支付宝明细列表", notes = "分页查询支付宝明细列表", response = AlipayDetailInfoVo.class)
    @ApiOperationSupport(order = 1)
    @PostMapping("/alipayDetail/findAlipayDetailList")
    public Object findAlipayDetailList(@RequestBody AlipayDetailQuery alipayDetailQuery){
        return alipayDetailService.findAlipayDetailList(alipayDetailQuery);
    }

    @ApiOperation(value = "查询交易类型下拉列表", notes = "查询交易类型下拉列表", response = SelectKeyVo.class)
    @ApiOperationSupport(order = 2)
    @PostMapping("/alipayDetail/findTypeListSelected")
    public Object findTypeListSelected(){
        List<SelectKeyVo> selectKeyVoList = new ArrayList<>();
        AlipayTypeEnum[] alipayTypeEnumArr = AlipayTypeEnum.values();
        if(alipayTypeEnumArr != null && alipayTypeEnumArr.length > 0){
            for (AlipayTypeEnum alipayTypeEnum : alipayTypeEnumArr){
                SelectKeyVo selectKeyVo = new SelectKeyVo();
                selectKeyVo.setKey(String.valueOf(alipayTypeEnum.getId()));
                selectKeyVo.setValue(alipayTypeEnum.getDesc());
                selectKeyVoList.add(selectKeyVo);
            }
        }
        return selectKeyVoList;
    }

    @ApiOperation(value = "查询支付宝支付页面", notes = "查询支付宝支付页面", response = AlipayDetailCreateVo.class)
    @ApiOperationSupport(order = 3)
    @PostMapping("/alipayDetail/findAlipayUrl")
    public Object findAlipayUrl(@RequestBody AlipayDetailAlipayUrlDao alipayDetailAlipayUrlDao){
        return alipayDetailService.findAlipayUrl(alipayDetailAlipayUrlDao);
    }

}
